public class Solution {
    //求给位数的平放和
    public int func(int n) {
        int sum = 0;
        while (n != 0) {
            int t = n % 10;
            sum = sum + t * t;
            n = n / 10;
        }
        return sum;
    }
        public boolean isHappy(int n){
            int slow = n;
            int fast = func(n);
            while (slow != fast) {
                slow = func(slow);
                fast = func(func(fast));

            }
            return (slow == 1);
        }

    public static void main(String[] args) {

    }
    }
